package com.ibm.ops.domain.report;

import com.ibm.ops.OpstoolConstant;
import com.ibm.ops.domain.OpsLogMetaDataType;
import com.ibm.ops.domain.metadata.OpsAuditLogCIRReportMetaData;
import com.ibm.ops.domain.metadata.OpsAuditLogReportMetaData;

public class OpsAuditLogCIRReport extends OpsAuditLogReport {

	@Override
	protected OpsAuditLogReportMetaData constructOpsAuditLogReportMetaData(String metaData) {
		OpsAuditLogCIRReportMetaData cirMetaData = new OpsAuditLogCIRReportMetaData();
		cirMetaData.setType(OpsLogMetaDataType.CIR);
		cirMetaData.setCntr_no(this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_CNRT_NO_START_IX, OpstoolConstant.CIR_REPORT_CNRT_NO_START_IX + OpstoolConstant.CIR_REPORT_CNRT_NO_LENGTH));
		cirMetaData.setStatus(this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_STATUS_START_IX, OpstoolConstant.CIR_REPORT_STATUS_START_IX + OpstoolConstant.CIR_REPORT_STATUS_LENGTH));
		cirMetaData.setSender(this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_SENDER_START_IX, OpstoolConstant.CIR_REPORT_SENDER_START_IX + OpstoolConstant.CIR_REPORT_SENDER_LENGTH));
		cirMetaData.setRecipient(this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_RECIPIENT_START_IX, OpstoolConstant.CIR_REPORT_RECIPIENT_START_IX + OpstoolConstant.CIR_REPORT_RECIPIENT_LENGTH));
		cirMetaData.setTrans_type(this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_TRANS_TYPE_START_IX, OpstoolConstant.CIR_REPORT_TRANS_TYPE_START_IX + OpstoolConstant.CIR_REPORT_TRANS_TYPE_LENGTH));
		cirMetaData.setLogtime_in(this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_LOGTIME_IN_START_IX, OpstoolConstant.CIR_REPORT_LOGTIME_IN_START_IX + OpstoolConstant.CIR_REPORT_LOGTIME_IN_LENGTH));
		this.currentMetaData = cirMetaData;
		return cirMetaData;
	}

	@Override
	protected OpsAuditLogReportMetaDataKey retrieveOpsAuditLogReportMetaDataKey(String metaData) {
		String key = null;
		if(this.currentMetaData != null){
			if(this.currentMetaData instanceof OpsAuditLogCIRReportMetaData){
				OpsAuditLogCIRReportMetaData obj = ((OpsAuditLogCIRReportMetaData) this.currentMetaData);
				key = obj.getLogtime_in();
			}			
		}else{
			key = this.retrieveData(metaData, OpstoolConstant.CIR_REPORT_LOGTIME_IN_START_IX, OpstoolConstant.CIR_REPORT_LOGTIME_IN_START_IX + OpstoolConstant.CIR_REPORT_LOGTIME_IN_LENGTH);
		}
		return new OpsAuditLogReportMetaDataKey(key);
	}

	
}
